package com.ltf.order.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.ltf.common.dto.ResponseDTO;
import com.ltf.order.annotation.Greeting;
import com.ltf.order.pojo.OrderInfo;
import com.ltf.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: liutf
 * @Date: 2025/3/24
 * @Description: com.ltf.order.controller
 * @version: 1.0
 */

//@RequestMapping("/api/order")
@RefreshScope
@RestController
public class OrderController {

    @Value("${order.timeout}")
    String orderTimeout;

    @Value("${order.auto-confirm}")
    String orderAutoConfirm;

    @Autowired
    OrderService orderService;

    @PostMapping("/insertOrder")
    public ResponseDTO insertOrder(@RequestBody OrderInfo order) {
        try{
            orderService.insertOrder(order);
            return ResponseDTO.success();
        }catch (Exception e){
            System.out.println(e.getMessage());
            return ResponseDTO.failed("创建失败");
        }
    }

    @GetMapping("/getWeather")
    public ResponseDTO getWeather(@RequestParam String area) {
        return ResponseDTO.success(orderService.getWeather(area));
    }


}
